<%@ page import="java.awt.*" %>
<%@ page import="java.awt.image.BufferedImage" %>
<%@ page import="javax.imageio.ImageIO" %>
<%@ page import="java.io.OutputStream" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="UTF-8"%>
<% String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() +
					":" + request.getServerPort()  + path + "/";%>

	<%
        response.setHeader("Pragma","No-cache");
        response.setHeader("Cache-Control","no-cache");
        response.setDateHeader("Expires", 0);
        //表明生成的响应是图片
        response.setContentType("image/jpeg");
//		Canvas canvas = new Canvas();
        OutputStream outputStream = response.getOutputStream();
//		canvas.setSize(300,200);
        BufferedImage bufferedImage = new BufferedImage(150, 50, BufferedImage.TYPE_INT_RGB);
//		Graphics2D graphics2D = new Graphics();
        Graphics2D graphics2D =  bufferedImage.createGraphics();
//        graphics2D.setBackground(Color.white);
        graphics2D.setColor(Color.gray);
        graphics2D.fillRect(0,0,300,50);
        Font font1 = new Font("黑体", Font.BOLD,24);
        graphics2D.setColor(new Color(0,255,255));
        graphics2D.setFont(font1);
		graphics2D.drawString("测试",100,20);

        graphics2D.setStroke(new BasicStroke(10));
        graphics2D.setColor(Color.GREEN);
        graphics2D.drawLine(10,50,270,1);
        ImageIO.write(bufferedImage, "jpeg",outputStream);
        System.out.println("图片写入4");
//		canvas.paint(canvas.getGraphics());
	%>